package cn.neusoft.luofa603.yuejian_29.activity;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

import cn.neusoft.luofa603.yuejian_29.Global;
import cn.neusoft.luofa603.yuejian_29.R;
import cn.neusoft.luofa603.yuejian_29.adapter.MasterInfoAdapter;
import cn.neusoft.luofa603.yuejian_29.bean.Club;
import cn.neusoft.luofa603.yuejian_29.bean.Master;
import cn.neusoft.luofa603.yuejian_29.fragment.AskMasterFragment;
import cn.neusoft.luofa603.yuejian_29.fragment.MasterVideoFragment;

public class MasterInfoActivity extends AppCompatActivity {
    private TabLayout tabs;
    public Master master;
    private String photo;
    private ScrollView master_sv;
    private Button iv_return;
    private TextView real_name,master_intro,province,city;
    private ImageView master_img;
    private ViewPager viewPager;

    private List<String> mTitle = new ArrayList<String>();
    private List<Fragment> mFragment = new ArrayList<Fragment>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_masterinfo);
        initViews();
        initEvents();
        initData();
        MasterInfoAdapter masterinfoAdapter = new MasterInfoAdapter(getSupportFragmentManager(),mTitle,mFragment);
        viewPager.setAdapter(masterinfoAdapter);
        tabs.setupWithViewPager(viewPager);

    }
    public void initViews(){
//        master_sv=(ScrollView)findViewById(R.id.master_sv);
        iv_return=(Button)findViewById(R.id.iv_return);
        real_name=(TextView)findViewById(R.id.real_name);
        master_intro=(TextView)findViewById(R.id.master_intro);
        province=(TextView)findViewById(R.id.province);
        city=(TextView)findViewById(R.id.city);
        master_img=(ImageView)findViewById(R.id.master_img);
        tabs = (TabLayout) findViewById(R.id.Tab_master);
        viewPager = (ViewPager)findViewById(R.id.master_vp);
        mTitle.add("大师带你练");
        mTitle.add("问大师");
        mFragment.add(new MasterVideoFragment());
        mFragment.add(new AskMasterFragment());


    }
    public void initEvents(){
        iv_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

    }
    public void initData(){
        getMaster();
    }
    public void getMaster(){
        final Bundle bundle=getIntent().getExtras();
        master = (Master) bundle.getSerializable("Master");
        real_name.setText(master.getRealname());
        master_intro.setText(master.getIntroduction());
        province.setText(master.getProvince_name());
        city.setText(master.getCity_name());
        photo=master.getThumb();
        Picasso.with(MasterInfoActivity.this).load(Global.PIC+photo).into(master_img);

    }
}
